<?php 
include TMPL_PATH.'public/header.phtml';
?>
<style type='text/css'>
.table_form tbody td{ border: 1px solid #EEEEEE;}
.division {
    background: none repeat scroll 0 0 #FFFFFF;
    border-color: #CCCCCC #BEC6CE #BEC6CE #CCCCCC;
    border-style: solid;
    border-width: 1px 2px 2px 1px;
    line-height: 150%;
    white-space: normal;
}
.division table {
    margin: 0;
    padding: 0;
}
.division th, .division td {
    border-color: #FFFFFF #DBE2E7 #DDDDDD #FFFFFF;
    border-left: 1px solid #FFFFFF;
    border-right: 1px solid #DBE2E7;
    border-style: solid;
    border-width: 1px;
    padding: 5px;
    vertical-align: top;
}
.division th {
    background: none repeat scroll 0 0 #E2E8EB;
    border-right: 1px solid #CCCCCC;
    font-size: 14px;
    text-align: right;
    white-space: nowrap;
    width: 140px;
}
.gridlist th{
	text-align:center;
	font-weight: bold;
	font-size: 12px;
}
.order_th{font-size: 14px; color: rgb(0, 0, 0); font-weight: bold; margin: 10px;overflow:hidden;}
</style>
<style type='text/css'>
.pic {
    float: left;
    margin-right: 10px;
    text-align: center;
}
.pic img {
    border: 3px solid #EFEFED;
    cursor: pointer;
}
.pic img.current {
    border: 3px solid #FF6600;
}
</style>
<div class="subnav">
    <div class="content-menu ib-a blue line-x" style="overflow:hidden;">
        <a href='<?php echo U('order/pay_return_list');?>'><em>退款/重做列表</em></a><span>|</span>
        <a href='javascript:;' class="on"><em>编辑<?php echo $pay['apply_type'] == 1 ? '重做' : '退款';?></em></a>
    </div>
</div>

<div class="pad-10">
<div class="col-tab">

<div class="order_th">申请信息 </div>
<div id="div_setting_1" class="contentList division pad-10">
<table width="100%" class="table_form">
	<tbody>
		<tr> 
		<th width="100">订单号：</th> 
		<td><?php echo $order['order_sn']?></td>
		</tr>
		<tr>
		<tr> 
		<th width="100">相关图片：</th> 
		<td>
			<?php 
				if($comment_photo):
					foreach ($comment_photo as $key=>$file):
			?>
						<span id="a<?php echo $file['fid'];?>" class="pic">
								<img name="img_name" <?php if(strpos($comment['img'],$file['img'])!==false){?>class="current"<?php }?> style="margin: 5px; opacity: 1;" src="<?php echo $file['thumb']?>" onclick="focus_img('<?php echo $file['img'];?>',this)"  <?php if($file['img'] == $product['img']):?>class="current"<?php endif;?> />
							</span>
			<?php 
					endforeach;
				endif;
			?>        
        </td>
		</tr>
		<tr>
		<th width="100">申请金额：</th> 
		<td><?php echo $pay['apply_amount']?></td>
		</tr>         
		<tr> 
		<th width="100"><?php echo $pay['apply_type'] == 1 ? '重做' : '退款';?>原因：</th> 
		<td><?php echo $pay['admin_note']?></td>
		</tr> 
		<tr> 
		<th width="100">申请人：</th> 
		<td><?php echo $pay['admin_user']?></td>
		</tr> 
        <tr> 
        <th width="100">申请时间：</th> 
        <td><?php echo isset($pay['add_time']) ? date('Y-m-d H:i:s', $pay['add_time']) : null;?></td>
        </tr>                        
</tbody>
</table>
</div>

<div class="order_th">商品信息 </div>
<div id="div_setting_2" class="contentList division pad-10">
<div class="table-grid" style="border: 1px solid #efefef;">
	<table width="100%" cellspacing="0" cellpadding="2" border="0" class="gridlist" id="order_items"> 
		<thead> 
			<tr>
			 <th style="width:10%;">货号</th> 
			 <th style="width:25%;">商品名称</th>
			 <th style="width:30%;">身形数据</th>
             <th style="width:6%">特殊要求</th>
			 <th style="width:5%;">设计师</th>
			 <th style="width:5%;">价格</th> 
			 <th style="width:5%;">购买数量</th> 
			 <th style="width:5%;">小计</th> 		 
			</tr> 
		</thead> 
		<tbody>

		<?php 
		if(isset($order['product']) && $order['product']):
			foreach ($order['product'] as $key => $product):
		?>
		<?php 
			if($product['product_name']){
				$where_name = array('product_id'=>$product['product_id'],'language_id'=>6);
				$product_items = D('product_items')->where($where_name)->find();
			}	//var_dump($product_items);die;
            $suppliers = M('suppliers')->where(array('suppliers_id'=>$product['suppliers_id']))->find();
            if($suppliers){
                $product['attr'] .= ' ,面料编号: '.$suppliers['suppliers_name']; 
            }
		?>
			<tr> 
				<td align="center"><?php echo $product['product_sn'];?><br /><?php echo $product['order_id'].'-'.$product['id'];?></td> 
				<td style="word-break:break-all">
				<?php echo $product_items['name'];if($product['attr']){echo ' ( '. $product['attr'] . ' )';}?>
				<?php
                    if($product['pants_qty'] > 0){
                       echo "<hr />";
                       echo "加同款单裤:".$product['pants_qty']."条 (".$product['pants_price']."X".$product['pants_qty'].")";						    
                    }
                ?>               
                </td> 
				<td>
				<?php if(isset($product['measure_data']) && $product['measure_data'] ):?>
				<div class="contentList division pad-10 ">
				<table width="100%" cellspacing="0" cellpadding="0" border="0" class="table_form"> 
					<tbody>
					<tr><td colspan="2">身形数据所有人：</td><td><?php echo $product['measure_data']['measure_name']?></td>
                    <th colspan="2">量体方式：</th><td colspan="2">
                                    <?php 
                                    $status = $product['measure_data']['m_status'];
                                    if($status == 1){
                                        echo '量尺量体';
                                    }else if($status == 2){
                                        echo '免量体';
                                    }else if($status == 3){
                                        echo '拍照量体';
                                    }else if($status == 4){
                                        echo '量尺并拍照';
                                    }
                                    ?>
                                </td><tr>
                            <tr>
                                <?php 
                                    $data = $product['measure_data']['measure_data'];
                                    echo "<tr><th style='width:50px'>年龄</th><td>{$product['measure_data']['age']}</td>"
                                    . "<th >身高</th><td>{$product['measure_data']['height']}cm</td>"
                                    . "<th >体重</th><td>{$product['measure_data']['weight']}kg</td>"
                                    . "<th style='width:50px'>上衣尺码</th><td>{$product['measure_data']['clothes_size']}</td>"
                                    . "<th style='width:50px'>裤子尺码</th><td>{$product['measure_data']['pants_size']}</td></tr>";
                                    if($status == 2){
                                        echo "<tr><td>chest</td><td>{$data['chest']['type']}</td><td>stomach</td><td>{$data['stomach']['type']}</td><td>shoulder</td><td>{$data['shoulder']['type']}</td><td>posture</td><td>{$data['posture']['type']}</td><td></td><td></td></tr>";
                                    }
                                    if(($status == 3 || $status == 4) || ($product['measure_data']['front_img'] && $product['measure_data']['side_img'])){
                                       echo  "<tr><td></td><td colspan='4'><img width=200 src='{$product['measure_data']['front_img']}'></td><td></td><td colspan='4'><img width=200 src='{$product['measure_data']['side_img']}'></td></tr>";
                                    }
                                    if($status == 1 || $status == 4){
                                    $i=0;
                                    foreach ($data as $key => $val){
                                        if($i==0 || $i%5==0){
                                            echo '<tr>';
                                        }
                                        if(in_array($key,array('age','weight','height'))){
                                            continue;
                                        }
                                        echo '<th style="width:50px">'. $key.'</th><td>';
                                        if(is_array($val)){
                                            foreach ($val as $key2 => $val2){
                                                if($key2=='type'){
                                                    echo $val2.'&nbsp;';
                                                }else{
                                                    echo $val2.$key2.' ';
                                                }
                                            }
                                        }else{
                                            echo  $val;
                                        }
                                        echo  '</td>';
                                        if(($i+1)%5==0){
                                            echo '</tr>';
                                        }
                                        $i++;
                                        }
                                    }
                                   ?>
				 </tbody>
				</table>
				</div>
				<?php endif;?>
				</td>
                <td align="center"><textarea name="special_request[<?php echo $product['id']?>]" rows="8"><?php echo $product['special_request'];?></textarea></td>
				<td align="center"><?php echo $product['designer_id'] ? $designerList[$product['designer_id']]['username'] : '--';?></td> 
				<td align="center"><?php echo $product['pay_price'];?></td> 
				<td align="center"><?php echo $product['qty'];?></td> 
				<td align="center"><?php echo $product['total_amount'];?></td>
                </tr> 
		<?php 
			endforeach;
		endif;
		?>
		<tr>
			<td colspan="8" style="text-align: right;width:100%">
			商品总金额：<?php echo $order['product_amount']?>
			</td>
		</tr>
		
		
		</tbody> 
	</table>	
</div></div>
	<div class="order_th">费用信息 </div>
	<div id="div_setting_2" class="contentList division pad-10">
<div class="table-grid" style="border: 1px solid #efefef;">
	<table width="100%" cellspacing="0" cellpadding="2" border="0" class="gridlist"  style="text-align: right;width:100%">
	 <tbody>
	 <tr>
			<td>
				商品总金额：<?php echo $order['product_amount']?>
				<?php if($order['payment_fee']){?>
        + 支付费用：<?php echo $order['payment_fee'];?> 
        <?php } if($order['shipping_fee']){?>
         <!-- 配送费用 -->
        + 配送费用：<?php echo $order['shipping_fee'];?> 
        <?php }?>
				= 订单总金额：<?php echo $order['order_amount']?>
			</td>
		</tr>

<?php if($order['discount_amount']>0):?>
<tr><td>-优惠金额：<?php echo $order['discount_amount'];?></td></tr>
<?php elseif($order['payment_status'] == OrderModel::PAY_UNPAYED):?>
		<tr><td>-优惠金额：<input name="discount_amount" type="text" value="" id="discount_amount"><input type="button" value="提交" id="discount_amount_submit"></td></tr>
<?php endif;?>

		<tr>
			<td>
				<?php if($order['product_dingjin']>0 && $order['payment_status']>0):?>
					-定金：<?php echo $order['product_dingjin'];?>
				<?php endif;?>
				<?php if($order['hongbao_money']>0):?>
					-红包：<?php echo $order['hongbao_money'];?>
				<?php endif;?>
				<?php if(($order['coupon_money']>0 && $coupon_info['status'] == 4) || $coupon_info['type'] == 4):?>
					-使用折扣优惠码 折扣率<?php echo $coupon_info['coupon_money']?>%：<?php echo $order['coupon_code'];?>
				<?php else:?>
					-使用优惠码编号：<?php echo $order['coupon_code'];?>
				<?php endif;?>
				<?php if($order['coupon_money']>0):?>
					-优惠码金额：<?php echo $order['coupon_money'];?>
				<?php endif;?>
		
				<?php if($order['surplus_money']){?>
        - 使用余额：<?php echo $order['surplus_money'];?>
        <?php }?>
				<?php if($order['integral_money']){?>
        - 使用积分：<?php echo $order['integral_money'];?>
        <?php }?>
				= 应付金额：<span id="pay_amount_html"><?php echo $order['pay_amount']?></span>
			</td>
		</tr>
	 	</tbody>
	</table>  
</div>
</div>


<div class="order_th">处理申请 </div>
<div id="div_setting_1" class="contentList division pad-10">
<table width="100%" class="table_form">
	<tbody>
		<tr>
		<th>申请状态：</th> 
		<td>
		<?php
            if($pay['status']==3){
                echo "已拒绝";
            }elseif($pay['status']==2){
                echo $pay['apply_type'] == 1 ? '重做' : '退款';echo "完成";
            }elseif($pay['status']==1){
                echo "审核通过";
            }elseif($pay['status']==0){
                echo "未处理";
            }
        ?>
        </td>
		</tr> 
		<?php if($pay['status']==3): ?>           
		<tr>
		<th>拒绝原因：</th> 
		<td>
        <?php echo isset($pay['refuse_note']) ? $pay['refuse_note'] : null;?>
        </td>
        </tr>
        <?php endif; ?>           
		<?php if($pay['status']!=0): ?>           
		<tr>
		<th>退款金额：</th> 
		<td>
		<?php echo isset($pay['return_amount']) ? $pay['return_amount'] : null;?>
        </td>
		</tr>
        <?php endif; ?>        
		<?php if($pay['status']==0): ?>           
		<tr>
		<th>退款金额：</th> 
		<td>
        <form name="myform" id="myform" action="__SELF__" method="post">
        <input type="text" name="return_amount" value="<?php echo isset($pay['return_amount']) ? $pay['return_amount'] : null;?>" class="input-text" id="return_amount"/>
        <input type="hidden" name="status" value="1" />
        <input type="submit" name="dosubmit" value=" 提 交 " />
        </form>
        </td>
		</tr>
		<tr>
		<th>拒绝原因：</th> 
		<td>
        <form name="myform" id="myform" action="__SELF__" method="post">
        <textarea rows="3" cols="55" name="refuse_note"><?php echo isset($pay['refuse_note']) ? $pay['refuse_note'] : null;?></textarea>
        <input type="hidden" name="status" value="3" />
        <input type="submit" name="dosubmit" value=" 拒 绝 " />
        </form>
        </td>
        </tr>
        <?php endif; ?>       
		<?php if($pay['status']==1): ?> 
		<tr>
		<th>操作：</th> 
		<td>
        <form name="myform" id="myform" action="__SELF__" method="post">
        <input type="hidden" name="status" value="2" />
        <input type="submit" name="dosubmit" value=" <?php echo $pay['apply_type'] == 1 ? '重做' : '退款';?>完成 " />
        </form>
        </td>
        </tr>
        <?php endif; ?>         
</tbody>
</table>
</div>

<div class="order_th">操作人记录</div>
<div id="div_setting_1" class="contentList division pad-10">
<table width="100%" class="table_form">
    <thead>
     <tr>
      <th style="width:80px;">操作者</th>
      <th style="width:150px;">操作时间</th>
      <th style="width:80px;">操作状态</th>
      <th style="width:500px;">备注</th>
     </tr> 
    </thead>  
	<tbody>
    <?php foreach($pay_return_log as $key=>$val):?>    
        <tr>
        <td><?php echo $val['action_name'];?></td>
        <td><?php echo date('Y-m-d H:i:s',$val['action_time']);?></td>         
        <td>
		<?php
            if($val['payt_status']==3){
                echo "已拒绝";
            }elseif($val['payt_status']==2){
                echo "操作完成";
            }elseif($val['payt_status']==1){
                echo "审核通过";
            }elseif($val['payt_status']==0){
                echo "未处理";
            }
        ?>        
        </td>  
        <td><?php echo $val['action_notice'];?></td>     
        </tr>
    <?php endforeach;?>    
    </tbody>   
</table>
</div>

<div class="bk15"></div>
    <!--<input name="dosubmit" type="submit" value="提交"  class="button" id="dosubmit" />-->
</div>
</div>
</body>
</html>
<script type="text/javascript">
function focus_img(little,obj)
{
	window.open(little);
}
</script>